package org.jeeasy.generate.emuns;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.jeeasy.common.core.enums.IDictEnum;


/**
 * 验证规则
 *
 * @author jackpeng
 * @date 2020/03/04
 */
@Getter
@AllArgsConstructor
public enum ValidRuleEnum implements IDictEnum<String> {
    PATTERN("pattern", "正则表达式"),
    MOBILE_PHONE("mobilePhone", "手机号码"),
    PHONE("phone", "电话号码"),
    EMAIL("email", "邮箱"),
    ID_CARD("idCard", "身份证"),
    IP("ip", "ip地址"),
    IPV4("ipv4", "ipv4地址"),
    IPV6("ipv6", "ipv6地址"),
    URL("url", "url地址"),
    // 银行卡号
    BANK_CARD("bankCard", "银行卡号"),
    // 密码
    PASSWORD("password", "密码"),
    // 密码
    PASSWORD_STRONG("passwordStrong", "强密码"),

    ;
    private final String value;
    private final String text;

    public static ValidRuleEnum getByValue(String value) {
        for (ValidRuleEnum item : ValidRuleEnum.values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return ValidRuleEnum.PATTERN;
    }
}
